package de.syfy.project.game.base;

import de.syfy.project.game.CharacterModel;
import de.syfy.project.game.GamePanel;
import java.awt.geom.Point2D;
import java.util.Random;

public class Punch extends Skill {

    public Punch(CharacterModel besitzer) {
        super("Punch!", new Float(0.1) , besitzer);
    }
 
    @Override
    public void use() {
        
        if(this.cdReady()){
            super.use();
            System.out.println("punch");
            Point2D.Float p = new Point2D.Float(0, 0);
            switch(besitzer.getFace()){
                case NORD: 
                    p = new Point2D.Float(besitzer.getPosition().x-5,besitzer.getPosition().y);
                    break;
                case OST:
                    p = new Point2D.Float(besitzer.getPosition().x,besitzer.getPosition().y+5);
                    break;
                case SUED:
                    p = new Point2D.Float(besitzer.getPosition().x+5,besitzer.getPosition().y);
                   break;
                case WEST:
                    p = new Point2D.Float(besitzer.getPosition().x,besitzer.getPosition().y-5);
                    break;
                
            }
            CharacterModel aim =(CharacterModel) GamePanel.getGameInstance().getActualWorld().getSpritesInRange(p, 5).get(0);
            Random r = new Random();
            System.out.println(besitzer.getCharacter().getCharValue());
            if(this.besitzer.getCharacter().getCharValue().meleekrit > r.nextFloat()){
                aim.getHit( aim.getCharacter().getCharValue().getHp() - this.besitzer.getCharacter().getCharValue().strength * 2);
                System.out.println(aim.getCharacter().getCharValue().getHp() - this.besitzer.getCharacter().getCharValue().strength * 2);
            }else {
                aim.getHit(aim.getCharacter().getCharValue().getHp() - this.besitzer.getCharacter().getCharValue().strength);
                System.out.println(aim.getCharacter().getCharValue().getHp() - this.besitzer.getCharacter().getCharValue().strength );
            }
            
            
            
        }else{
            decCD();
        }
        }

    @Override
    public boolean cdReady() {
        return runningCD == 0;
    }

    @Override
    public void decCD() {
        super.decCD();
    }
    
}
